{include file=header.html}
{include file="title.html"}
<script type="text/javascript">
    //<!CDATA[
    $(function() {
        regionInit("region");

        $("#apply_form").validate({
            errorPlacement: function(error, element) {
                $(element).after(error);
            },
            rules: {
                owner_name: {
                    required: true
                },
                store_name: {
                    required: true,
                    remote: {
                        url: 'index.php?app=apply&act=check_name&ajax=1',
                        type: 'get',
                        data: {
                            store_name: function() {
                                return $('#store_name').val();
                            },
                            store_id: '{$store.store_id}'
                        }
                    },
                    maxlength: 20
                },
                tel: {
                    required: true,
                    minlength: 6,
                    checkTel: true
                },
                image_1: {
                    accept: "jpg|jpeg|png|gif"
                },
                image_2: {
                    accept: "jpg|jpeg|png|gif"
                },
                image_3: {
                    accept: "jpg|jpeg|png|gif"
                },
                notice: {
                    required: true
                }
            },
            messages: {
                owner_name: {
                    required: '{$lang.input_owner_name}'
                },
                store_name: {
                    required: '{$lang.input_store_name}',
                    remote: '{$lang.name_exist}',
                    maxlength: '{$lang.note_for_store_name}'
                },
                tel: {
                    required: '{$lang.input_tel}',
                    minlength: '{$lang.phone_tel_error}',
                    checkTel: '{$lang.phone_tel_error}'
                },
                image_1: {
                    accept: '{$lang.select_valid_image}'
                },
                image_2: {
                    accept: '{$lang.select_valid_image}'
                },
                image_3: {
                    accept: '{$lang.select_valid_image}'
                },
                notice: {
                    required: '{$lang.check_notice}'
                }
            }
        });
    });
    //]]>
</script>
<form method="post" enctype="multipart/form-data" id="apply_form">
    <ul class="form_content">
        <li>
            <h2>{$lang.owner_name}</h2>
            <p><input type="text" name="owner_name" value="{$store.owner_name|escape}" id="owner_name" /></p>
        </li>
        <li>
            <h2>{$lang.owner_card}</h2>
            <p><input type="text" name="owner_card" value="{$store.owner_card|escape}"  id="owner_card" /></p>
        </li>
        <li>
            <h2>{$lang.store_name}</h2>
            <p><input type="text" name="store_name" value="{$store.store_name|escape}" id="store_name"  /></p>
        </li>
        <li>
            <h2>{$lang.store_category}</h2>
            <p>
                <select name="cate_id">
                    <option value="0">{$lang.select_pls}</option>
                    {html_options options=$scategories selected=$scategory.cate_id}
                </select>
            </p>
        </li>
        <li>
            <h2>{$lang.region}</h2>
            <p id="region">
                <input type="hidden" name="region_id" value="{$store.region_id}" class="mls_id" />
                <input type="hidden" name="region_name" value="{$store.region_name}" class="mls_names" />
                {if $store.region_name}
                <span>{$store.region_name|escape}</span>
                <input type="button" value="{$lang.edit}" class="edit_region" />
                {/if}
                <select class="d_inline"{if $store.region_name} style="display:none;"{/if}>
                        <option value="0">{$lang.select_pls}</option>
                    {html_options options=$regions}
                </select>
            </p>
        </li>
        <li>
            <h2>{$lang.address}</h2>
            <p><input type="text" name="address" value="{$store.address|escape}" id="address" /></p>
        </li>
        <li>
            <h2>{$lang.zipcode}</h2>
            <p><input type="text" name="zipcode" value="{$store.zipcode|escape}" id="zipcode" /></p>
        </li>
        <li>
            <h2>{$lang.tel}</h2>
            <p><input type="text" name="tel"  value="{$store.tel|escape}" id="tel" /></p>
        </li>
        <li>
            <h2>{$lang.upload_image} </h2>
            <p><input type="file" name="image_1" />{if $store.image_1}<p style="display:inline;"><a href="{$site_url}/{$store.image_1}" >{$lang.view}</a></p>{/if}</p>
        </li>
        <li>
            <h2>{$lang.upload_permit}</h2>
            <p><input type="file" name="image_2" />{if $store.image_2}<p style="display:inline;"><a href="{$site_url}/{$store.image_2}" >{$lang.view}</a></p>{/if}</p>
        </li>
        <li>
            <p style="margin:10px 0;"><input type="checkbox"{if $store} checked="checked"{/if} name="notice" value="1" id="warning" /> <label for="warning">{$lang.notice}</label></p>
        </li>
        <li>
            <input class="red_btn" type="submit" value="{$lang.application}" />
        </li>
    </ul>
</form>
{include file=footer.html}